<?php

require_once dirname(__FILE__) . '/init.php';
$arr_installed_subdomains = get_all_installed_site_subdomains();
$arr_installed_maindomains = get_main_domains_by_subdomains($arr_installed_subdomains);
$arr_installed_maindomains = array_unique(array_filter($arr_installed_maindomains));
$allInstall_Maindomains = $arr_installed_maindomains;
$arr_installed_subdomains = array_unique(array_filter($arr_installed_subdomains));
$allInstall_Subdomains = $arr_installed_subdomains;

$fileAdsenseCsc7day_1 = dirname(__FILE__) . '/input/csv/7day_1.csv';
$fileAdsenseCsc30day_1 = dirname(__FILE__) . '/input/csv/30day_1.csv';
$fileAdsenseCsc7day_2 = dirname(__FILE__) . '/input/csv/7day_2.csv';
$fileAdsenseCsc30day_2 = dirname(__FILE__) . '/input/csv/30day_2.csv';
$fileAdsenseCsc7day_3 = dirname(__FILE__) . '/input/csv/7day_3.csv';
$fileAdsenseCsc30day_3 = dirname(__FILE__) . '/input/csv/30day_3.csv';

$arrGlobal7DaysDataMaindomain_1 = getCsvShouRuData($fileAdsenseCsc7day_1);
$arrGlobal30DaysDataMaindomain_1 = getCsvShouRuData($fileAdsenseCsc30day_1);
$arrGlobal7DaysDataMaindomain_2 = getCsvShouRuData($fileAdsenseCsc7day_2);
$arrGlobal30DaysDataMaindomain_2 = getCsvShouRuData($fileAdsenseCsc30day_2);
$arrGlobal7DaysDataMaindomain_3 = getCsvShouRuData($fileAdsenseCsc7day_3);
$arrGlobal30DaysDataMaindomain_3 = getCsvShouRuData($fileAdsenseCsc30day_3);

#统计所有已经安装的网站的收入信息
foreach ($allInstall_Maindomains as $Maindomain) {
    $arrUsdPvInfo = array();
    $arrUsdPvInfo['7day_1'] = $arrGlobal7DaysDataMaindomain_1[$Maindomain];
    $arrUsdPvInfo['7day_2'] = $arrGlobal7DaysDataMaindomain_2[$Maindomain];
    $arrUsdPvInfo['7day_3'] = $arrGlobal7DaysDataMaindomain_3[$Maindomain];
    $arrUsdPvInfo['30day_1'] = $arrGlobal30DaysDataMaindomain_1[$Maindomain];
    $arrUsdPvInfo['30day_2'] = $arrGlobal30DaysDataMaindomain_2[$Maindomain];
    $arrUsdPvInfo['30day_3'] = $arrGlobal30DaysDataMaindomain_3[$Maindomain];
    domain_fset($Maindomain, 'usdpv', $arrUsdPvInfo);
}

die();
/*
$arrGlobal7DaysDataMaindomain_1 = getCsvShouRuDataBySonDomain($fileAdsenseCsc7day_1);
$arrGlobal30DaysDataMaindomain_1 = getCsvShouRuDataBySonDomain($fileAdsenseCsc30day_1);
$arrGlobal7DaysDataMaindomain_2 = getCsvShouRuDataBySonDomain($fileAdsenseCsc7day_2);
$arrGlobal30DaysDataMaindomain_2 = getCsvShouRuDataBySonDomain($fileAdsenseCsc30day_2);
$arrGlobal7DaysDataMaindomain_3 = getCsvShouRuDataBySonDomain($fileAdsenseCsc7day_3);
$arrGlobal30DaysDataMaindomain_3 = getCsvShouRuDataBySonDomain($fileAdsenseCsc30day_3);

#统计所有已经安装的网站的收入信息
foreach ($allInstall_Subdomains as $Subdomain) {
    $arrUsdPvInfo = array();
    $arrUsdPvInfo['7day_1'] = $arrGlobal7DaysDataMaindomain_1[$Subdomain];
    $arrUsdPvInfo['7day_2'] = $arrGlobal7DaysDataMaindomain_2[$Subdomain];
    $arrUsdPvInfo['7day_3'] = $arrGlobal7DaysDataMaindomain_3[$Subdomain];
    $arrUsdPvInfo['30day_1'] = $arrGlobal30DaysDataMaindomain_1[$Subdomain];
    $arrUsdPvInfo['30day_2'] = $arrGlobal30DaysDataMaindomain_2[$Subdomain];
    $arrUsdPvInfo['30day_3'] = $arrGlobal30DaysDataMaindomain_3[$Subdomain];
    domain_fset($Subdomain, 'usdpv', $arrUsdPvInfo);
}

$keys71 = array_keys($arrGlobal7DaysDataMaindomain_1);
$keys72 = array_keys($arrGlobal7DaysDataMaindomain_2);
$keys73 = array_keys($arrGlobal7DaysDataMaindomain_3);
$keys301 = array_keys($arrGlobal30DaysDataMaindomain_1);
$keys302 = array_keys($arrGlobal30DaysDataMaindomain_2);
$keys303 = array_keys($arrGlobal30DaysDataMaindomain_3);

$allsubs = array_merge($keys71, $keys72, $keys73, $keys301, $keys302, $keys303, $arr_installed_subdomains);
$allsubs = array_unique(array_filter($allsubs));
foreach ($allsubs as $k => $item) {
    if (count($item) > 3) {
        unset($allsubs[$k]);
    }
}

#@unlink(dirname(__FILE__) . '/domainlist.txt');
#foreach ($allsubs as $item) {
    #file_put_contents(dirname(__FILE__) . '/domainlist.txt', $item . PHP_EOL,8);
#}
*/
?>